#include <stdio.h>
#include <stdbool.h>
#include <string.h>
//还未完成

bool judge_pre(char* s1, char* s2, int len)
{
    int count1[26] = {0};
    int count2[26] = {0};
    for(int i = 0; i < len; i++)
    {
        int p1 = s1[i] - 'a';
        int p2 = s2[i] - 'a';
        count1[p1] += 1;
        count2[p2] += 1;
    }
    for(int i = 0; i < 26; i++)
    {
        if(count1[i] != count2[i])
        return false;
    }
    return true;
}

bool judge_det(char* s1, char* s2, int len)
{
    if(len == 1 || len == 2)
    return true;
    int count1[26] = {0};
    int count2[26] = {0};
    int count3[26] = {0};

    for(int i = 0; i < len - 1; i++)
    {
        int flag1 = 1;
        int flag2 = 1;
        int p1 = s1[i] - 'a';
        int p2 = s2[i] - 'a';
        int p3 = s2[len - 1 - i] - 'a';
        count1[p1] += 1;
        count2[p2] += 1;
        count3[p3] += 1;
        for(int j = 0; j < 26; j++)
        {
            if(count1[j] != count2[j])
            {
                flag1 = 0;
            }
            if(count1[j] != count3[j])
            {
                flag2 = 0;
            }
        }
        bool ret = true;
        if(flag1)
        {
            ret = judge_det(s1, s2, i + 1);
            ret = (ret && judge_det(s1 + i + 1, s2 + i + 1, len - i - 1));
            if(ret == true)
            return true;
        }
        if(flag2)
        {
            ret = judge_det(s1, s2 + len - 1 - i, i + 1);
            ret = (ret && judge_det(s1 + i + 1, s2, len - i - 1));
            if(ret == true)
            return true;
        }
    }
    return false;
}

bool isScramble(char* s1, char* s2) {
    int len = strlen(s1);
    
    if(judge_pre(s1, s2, len) == false)
    return false;
    
    return judge_det(s1, s2, len);
}

int main()
{
    char* s1 = "great";
    char* s2 = "rgeat";
    if(isScramble(s1, s2))
    printf("yes\n");
    else
    printf("no\n");
    return 0;
}